package com.yiren.backstage.judge.services.sczb.impl;

import android.content.Context;

import com.yiren.backstage.config.enums.SiteConfigCodeEnum;
import com.yiren.backstage.currency.bean.CarStateBean;
import com.yiren.backstage.currency.bean.VoiceBean;
import com.yiren.backstage.currency.constant.SignalGConstant;
import com.yiren.backstage.currency.enums.CarStateValueEnum;
import com.yiren.backstage.judge.services.sczb.IPlayOperationVoiceService;
import com.yiren.backstage.player.api.PlayerApi;

/**
 * Time:2022/4/7 18:32
 * Author:xiaozan
 * Description：播报灯光操作语音服务实现
 */
public class PlayOperationVoiceServiceImpl implements IPlayOperationVoiceService {

    private Context context;
    private CarStateBean carStateBean;

    private boolean playHeadLeft;
    private boolean playHeadRight;
    private boolean playTailLeft;
    private boolean playTailRight;
    private boolean playSeat;
    private boolean playReflectorMirror;
    private boolean playRearviewMirror;

    public PlayOperationVoiceServiceImpl(Context context) {
        this.context = context;
        carStateBean = CarStateBean.getInstance();
    }


    @Override
    public void playHeadLeft() {
        if (!playHeadLeft && carStateBean.getCarHeadLeft() == CarStateValueEnum.PASS) {
            String headLeft = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S8.toString());
            if (!"".equals(headLeft)) {
                playHeadLeft = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(headLeft, ""), null);
            }
        }
    }

    @Override
    public void playHeadRight() {
        if (!playHeadRight && carStateBean.getCarHeadRight() == CarStateValueEnum.PASS) {
            String headRight = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S9.toString());
            if (!"".equals(headRight)) {
                playHeadRight = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(headRight, ""), null);
            }
        }
    }

    @Override
    public void playTailLeft() {
        if (!playTailLeft && carStateBean.getCarTailLeft() == CarStateValueEnum.PASS) {
            String tailLeft = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S10.toString());
            if (!"".equals(tailLeft)) {
                playTailLeft = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(tailLeft, ""), null);
            }
        }
    }

    @Override
    public void playTailRight() {
        if (!playTailRight && carStateBean.getCarTailRight() == CarStateValueEnum.PASS) {
            String tailRight = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S11.toString());
            if (!"".equals(tailRight)) {
                playTailRight = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(tailRight, ""), null);
            }
        }
    }

    @Override
    public void playSeat() {
        if (!playSeat && carStateBean.getSeat() == CarStateValueEnum.ADJUST) {
            String seat = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S13.toString());
            if (!"".equals(seat)) {
                playSeat = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(seat, ""), null);
            }
        }
    }

    @Override
    public void playReflectorMirror() {
        if (!playReflectorMirror && carStateBean.getReflectorMirror() == CarStateValueEnum.ADJUST) {
            String reflectorMirror = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S14.toString());
            if (!"".equals(reflectorMirror)) {
                playReflectorMirror = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(reflectorMirror, ""), null);
            }
        }
    }

    @Override
    public void playRearviewMirror() {
        if (!playRearviewMirror && carStateBean.getRearviewMirror() == CarStateValueEnum.ADJUST) {
            String rearviewMirror = (String) SignalGConstant.examConfigMap.get(SiteConfigCodeEnum.S15.toString());
            if (!"".equals(rearviewMirror)) {
                playRearviewMirror = true;
                PlayerApi.playProjectAndJudgeVoice(context, new VoiceBean(rearviewMirror, ""), null);
            }
        }
    }

}